<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Player on Server</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.18/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="https://laci2.esri.com/jenkins/job/report-player-jsapi-3.18-pr/lastSuccessfulBuild/artifact/build/report-player/release/reportPlayer/esri.css">
    <script src="https://laci2.esri.com/jenkins/job/report-player-jsapi-3.18-pr/lastSuccessfulBuild/artifact/build/report-player/release/reportPlayer/config.js"></script>
    <script data-dojo-config="baseUrl: 'https://laci2.esri.com/jenkins/job/report-player-jsapi-3.18-pr/lastSuccessfulBuild/artifact/build/report-player/release', isDebug: 1, waitSeconds: 60" src="https://laci2.esri.com/jenkins/job/report-player-jsapi-3.18-pr/lastSuccessfulBuild/artifact/build/report-player/release/reportPlayer/main.js"></script>

    <style>
        html, body, #layoutNode {
            padding: 0px;
            margin: 0px;
            height: 100%;
            overflow: hidden;
            font-size: 13px;
            background-color: #525659;
            font-family: "Avenir Next";
        }
    </style>

    <script>
        require([
            "dojo/when",

            "esri/dijit/geoenrichment/ReportPlayer/ReportPlayer",
            "esri/dijit/geoenrichment/ReportPlayer/dataProviders/DataProviderGE",
            "esri/dijit/geoenrichment/ReportPlayer/PlayerResizeModes",
            "esri/dijit/geoenrichment/ReportPlayer/dataProviders/commands/supportClasses/PlayerCommands",
            "esri/dijit/geoenrichment/utils/UrlUtil",
            "dojo/domReady!"
        ], function (
            when,
            ReportPlayer,
            DataProviderGE,
            PlayerResizeModes,
            PlayerCommands,
            UrlUtil) {

            function getVariable(name, defaultValue) {
                return UrlUtil.getVariableValue(window.location.href, name) || defaultValue || null;
            };

            esriConfig.defaults.io.proxyUrl = getVariable("proxy");

            var dataProvider = new DataProviderGE();
            dataProvider.registerCommand(PlayerCommands.PDF, "PDF");

            var player = new ReportPlayer({
                isSlidesView: false,
                dataProvider: dataProvider,
                resizeMode: PlayerResizeModes.FIT_WINDOW
            }).placeAt(layoutNode);

            /*
            var serverData = {
                portalUrl: getVariable("portalUrl"),
                files: JSON.parse(getVariable("files", "[]")),
                featureSets: JSON.parse(getVariable("featureSets", "[]")),
                studyAreas: JSON.parse(getVariable("studyAreas", "[]"))
            };
            */

            when(dataProvider._reportDataFromServerData(serverData), function (reportData) {
                when(player.setReportData(reportData, {
                    waitUntilAllContentIsReady: true
                }), function () {
                    when(player.executeCommand(PlayerCommands.PDF, { returnLayoutXMLOnly: true }), function (result) {
                        console.log(result);
                    });
                });
            });
        });
    </script>
</head>
<body class="claro" style="margin:0px;">
    <div id="layoutNode"></div>
</body>
</html>